<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>易公交</title>
<style type="text/css">

</style>
<link rel="stylesheet" type="text/css" href="css/main.css" />
<script language="javascript" src="js/jquery-1.5.2.min.js"></script>
<script language="javascript" src="js/classMap.js"></script>
<script language="javascript" src="js/ebus.tools.js"></script>
<script language="javascript">
function initVariables() {
	top.objPub = { baseUrl : window.location.href.replace(/[\w\.]*$/, '') };
}
	
//加载上行线路
function loadBusLine(busNumber) {
	var data = callAjax('busLineAction.do?method=getBusLine',{busNumber:busNumber});
	$("#lineNum").empty();
	$("#lineNum2").empty();
	$.each(data, function(idx, item) {
		if(item.busRunType) {
			loadBusLine0(item.busLine);
		}
		else {
			loadBusLine1(item.busLine);
		}
	});
	
	//拖动
	drag();
}

//加载上行线路
function loadBusLine0(busLine) {
	//var busLine = "1=月亮湾,2=荔湾路西,3=南山花园,4=深大附中,5=青青世界,6=前海沿湖路口,7=太子山庄,8=信诺公司,9=南山村西,10=鼎太风华,11=南头火车西站,12=阳光棕榈园,13=大新村,14=桃源康复中心,15=大学城南门,16=平山,17=路路口,18=平山路口,19=丽水路南,20=同富裕工业城,21=美康百货,22=塘朗村口,23=中科院研究院,25=塘朗小学,26=福光村";
	var busLineJson = string2Json(busLine);
	var len = busLineJson.length;
	$.each(busLineJson, function(idx, item) {
		if((idx + 1) < len) {
			$("#lineNum").append('<li><p>' + item.key + '</p><p><img src="img/list_line.gif" /></p><p><a>' + item.value + '</a></p></li>');
		}
		else {
			$("#lineNum").append('<li><p>' + item.key + '</p><p><img src="img/list_dot.gif" /></p><p><a>' + item.value + '</a></p></li>');
		}
	});
}

//加载下行线路
function loadBusLine1(busLine) {
	//var busLine = "1=大新村,2=阳光棕榈园,3=南头火车西站,4=鼎太风华,5=南山村西,6=信诺公司,7=太子山庄,8=前海沿湖路口,9=青青世界,10=深大附中,11=南山花园,12=荔湾路西,13=月亮湾";
	var busLineJson = string2Json(busLine);
	var len = busLineJson.length;
	$.each(busLineJson, function(idx, item) {		
		if((idx + 1) < len) {
			$("#lineNum2").append('<li><p>' + item.key + '</p><p><img src="img/list_line.gif" /></p><p><a>' + item.value + '</a></p></li>');
		}
		else {
			$("#lineNum2").append('<li><p>' + item.key + '</p><p><img src="img/list_dot.gif" /></p><p><a>' + item.value + '</a></p></li>');
		}		
	});
}

/**
 * 给id为_test_的DOM添加事件。 在该DOM上单击鼠标，然后拖动可以进入移动该DOM状态，再将单击取消移动状态
 */
function drag() {
	$busline1 = $(".lineDetails");	
	var _x_ = 0, _y_ = 0, pre_x_ = 0, pre_y_ = 0;
	var isMove = false;
	$busline1.mousedown(function(e) {
		isMove = true;
		_x_ = e.pageX;
		//_y_ = e.pageY;
		pre_x_ = parseInt($(this).css("margin-left"));
		//pre_y_ = parseInt($(this).css("top"));
	}).mousemove(function(e) {
		if(isMove) {
			$(this).css("margin-left", (pre_x_ + e.pageX - _x_) + "px");
		}		
	}).mouseup(function() {
		isMove = false;
	});
}

$(function() {
	initVariables();
	
	$searchInput = $("#searchInput");
	$searchInput.val("36");
	$searchInput.focus(function() {
		if($searchInput.val() == "36") {
			$searchInput.val("");
		}
	}).focusout(function() {
		if($searchInput.val() == "") {
			$searchInput.val("36");
		}
	});
	
	$("li>p").css("padding-left", "3px");
	
	$(".searchP").click(function() {
		var busNumber = $("#searchInput").val();
		loadBusLine(busNumber);
	});
	
	//加载线路图
	//loadBusLine();
	//loadBusLine1();
	//drag();
});

</script>
</head>
<body>
<div id="topDiv">
	<div id="divTopAd"></div>
	<div id="divTopBottom">
		<div id="divUserInfo">
		<p style="float: left;">余晖</p>，欢迎来到易巴士<a href="javascript:void(0)">我的账户</a></div>
		<div><input id="searchInput" maxlength="24"><p class="searchP">搜索</p></div>
	</div>
</div>
<div id="contentDiv">
	<div class="busDetails">深圳36路公交线路车</div>
	<div class="busline1">
		<div class="line2">
			月亮湾&nbsp;<img src="img/bus_arrowr.gif" />&nbsp;福光村&nbsp;&nbsp;(<strong style="color:red">26站</strong>)
		</div>
		<div class="LineC">
			<ul id="lineNum" class="lineDetails"></ul>
		</div>
		<div id="msg" class="msgDiv">
			<img src="img/bus_icon6.gif"/><span>票价：</span>2元&nbsp;&nbsp;
			<img src="img/bus_icon7.gif"/><span>运营时间：</span>往福光村方向：05:30-23:00		
		</div>
	</div>
	<div class="busline1">
		<div class="line2">
			大新村&nbsp;<img src="img/bus_arrowr.gif" />&nbsp;月亮湾&nbsp;&nbsp;(<strong style="color:red">13站</strong>)
		</div>
		<div class="LineC">
			<ul id="lineNum2" class="lineDetails"></ul>
		</div>
		<div id="msg2" class="msgDiv">
			<img src="img/bus_icon6.gif"/><span>票价：</span>2元&nbsp;&nbsp;
			<img src="img/bus_icon7.gif"/><span>运营时间：</span>往月亮湾方向：05:30-23:00		
		</div>
	</div>
</div>
<div id="bottomDiv">

</div>
</body>
</html>
